Skip to content

PRs-lines-changed: Add new userscript#221

Open
karthikeyann wants to merge 2 commits into
Mottie:masterfrom
karthikeyann:add-pr-lines-changed
Open

PRs-lines-changed: Add new userscript#221
karthikeyann wants to merge 2 commits into
Mottie:masterfrom
karthikeyann:add-pr-lines-changed

Conversation

@karthikeyann

@karthikeyann karthikeyann commented Jun 2, 2026

Copy link
Copy Markdown

What this adds

A new userscript, GitHub PRs lines changed, that:

  • Shows the added/removed line counts (+x -y) next to each pull request on PR list pages (e.g. /owner/repo/pulls).
  • Adds "Most lines changed" / "Least lines changed" options to GitHub's existing Sort menu.

How it works

Line counts (additions/deletions) are only available per pull request from the GitHub API, so the script:

  • Uses a single GraphQL request per repository (batched, up to 50 PRs per request) instead of one REST call per PR, to stay well within rate limits.
  • Caches results in localStorage for instant paint on revisits, then always re-queries so counts stay current when PRs get new commits.
  • Re-applies itself across GitHub's Turbo/PJAX navigations and re-renders via a MutationObserver, guarding its own DOM writes so it never reacts to itself.

Token requirement

Because the counts come from the API, the script needs a personal access token, requested once via the userscript manager menu ("Set GitHub token for PR line counts") and stored locally — never in the script file:

  • A classic token with no scopes is enough for public repositories.
  • For private repos, use repo (classic) or read-only fine-grained access.
  • Without a token the script stays dormant and makes no requests.

Checklist

  • Code is on a fork of master (branch add-pr-lines-changed).
  • Passes npx eslint with the repo's .eslintrc (0 errors/warnings).
  • Tabs, double quotes, semicolons, LF, trailing newline per .editorconfig.
  • Added a README table row + [plc-wiki]/[plc-raw] reference links (GF/OU links and the wiki page left for the maintainer to publish).
  • Manually tested on PR list pages with no console errors.

Happy to adjust the name, metadata, or token UX to better fit the project's conventions.

Show added/removed line counts on pull request list pages and add a
"lines changed" sort option to the existing sort menu. Counts are fetched
with a single GraphQL request per repository and cached locally, so a
personal access token (set via the userscript manager menu) is required.
@karthikeyann karthikeyann changed the title PR-lines-changed: Add new userscript PRs-lines-changed: Add new userscript Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant